import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { useLocalStorage } from '@vueuse/core'
import sysConfig from '@/config'


export const useGloabStore = defineStore('gloab', () => {

    // 语言
    const lang = useLocalStorage('LANG', sysConfig.LANG)
    // 主题
    const dark = useLocalStorage('DARK', sysConfig.DARK)

    // 获取语言
    const getLang = computed(() => lang.value)
    // 获取主题
    const getDark = computed(() => dark.value)

    // 设置语言
    function setLang(val) {
        lang.value = val
    }

    // 设置主题
    function setDark(val) {
        dark.value = val
    }
    
    
    return {
        lang,
        getLang,
        setLang
    }

})